package com.jstyle.jclifexd.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jstyle.jclifexd.R;
import com.jstyle.jclifexd.model.Activitities;
import com.jstyle.jclifexd.model.teamData;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SquadlistAdapter extends  RecyclerView.Adapter<BaseViewHolder>{
    List<teamData> Details;
    Context context;
    //私有属性
    private OnItemClickListener onItemClickListener = null;

    public interface OnItemClickListener {
        void onItemClick(Activitities aa, int position);
    }

    //setter方法
    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public SquadlistAdapter(Context mycontext) {
        this.context = mycontext;
        this.Details = new ArrayList<>();
    }

    public void SetData(List<teamData> myDetails) {
        this. Details = myDetails;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new ViewHolder( LayoutInflater.from(context).inflate(R.layout.item_squalist, viewGroup, false));
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(final BaseViewHolder holder, final int position) {
        final teamData sleepDetail = Details.get(position);
        final ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.tag_name.setText(sleepDetail.getTag()+":");
        viewHolder.name.setText(sleepDetail.getNickname());
        viewHolder.liveness.setText(context.getResources().getString(R.string.activityindex)+sleepDetail.getLiveness());
    }

    @Override
    public int getItemCount() {
        return null==Details?0:Details.size();
    }



    static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tag_name)
        TextView tag_name;
        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.liveness)
        TextView liveness;
        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
